package gdepot
enum CartStatus{ NEW ,ORDER }
class Cart {

    static hasMany = [lineItems:LineItem]
    static belongsTo = [user:User]
    CartStatus status=CartStatus.NEW

    Date createdDate = new Date()
    Date modifiedDate = new Date()


    public def totalPrice(){
        def price=0
        lineItems.each {price+=it.goods?.price *it.itemNumber}
        return price
    }
    def beforeUpdate(){
        modifiedDate = new Date()
    }
    static constraints = {
    }
}
